/*
Remove Element

Given an array and a value, remove all instances of that value in place and return the new length.

The order of elements can be changed. It doesn't matter what you leave beyond the new length.
*/

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <stack>
#include "print.h"
using namespace std;


void testForStack()
{
	stack<int> mystack;
	mystack.push(10);
	mystack.push(20);
	mystack.top() -= 5;
	cout << "mystack.top() is now " << mystack.top() << endl;
}
class Solution {
public:
	int removeElement(int A[], int n, int elem) {
		int len = 0;
		for (int i = 0; i < n; i++)
		{
			if (elem != A[i])
			{
				A[len++] = A[i];
			}
		}
		return len;
	}
};


int main(int argc, char* argv[])
{
	Solution s;
	string str;

	//testForStack();
	int len = argc - 1;
	int arrInt[1000];
	for (int i = 1; i < argc; i++){

		cout << argv[i] << endl;
		arrInt[i - 1] = atoi(argv[i]);
 		//str = argv[i];

	}

	cout << "The new length: "<<s.removeElement(arrInt,len, 2) << endl;



	system("pause");
	return 0;
}